Fix webpack filesystem cache script recovery#190
Conversation
|
@webdiscus I don't really intend for you to merge this PR. It's 100% AI coded, and I'm not really sure if the fixes it came up with are valid. |
|
Hello @davidmurdoch, thanks for the issue reporting and the PR. I will review it. I know, your project is very big, however I need a small as possible repo with reproducible issue, containing all needed files. As base you can take the issue-0-base-template. Please describe the steps to reproduce the issue. The unit test is not enough. I need to see the problem on application level. Help me to reproduce your pain by me local. Thanks. |
f850ff1 to
6c3e64d
Compare
|
I found a deterministic minimal reproduction using the existing small cache fixture in this repository; it does not require MetaMask or timing Steps on current npm ci
cd test/cases/cache-filesystem-js
rm -rf .cache dist
npx webpack --config webpack.config.js
npx webpack --config webpack.config.jsObserved on the second build from The first build succeeds but Webpack warns that I pushed an update to this PR that turns this into an application-level regression test by making |
Summary
Root cause
Webpack can restore cached HTML template modules that still contain generated
require(...)calls for script resources while the plugin collection cache is incomplete or stale. In that state the script file exists, but the plugin resolver no longer has script bookkeeping for it and throws a falseCannot resolve ...error during render manifest generation.A deterministic minimal reproduction is the existing
test/cases/cache-filesystem-jsfixture: itsjs.filenameoption is a function. Onmaster, the first build skips the plugin persistent cache as non-serializable, then the second build restores Webpack cached HTML modules without the plugin collection state and fails resolvingsrc/main.js.Validation
node -c src/Plugin/AssetCompiler.js && node -c src/Plugin/Collection.js && node -c src/Plugin/Resolver.jsnode -c test/utils/helpers.jsnpm test -- --runTestsByPath ./test/unit.test.jsnpm test -- --runTestsByPath ./test/integration.test.js -t "cache|use script in html"